// 导入request模块
import request from './request'

// 创建医生信息
export const createDoctor = (hospital, department, position) => {
	return request.post('/users/doctor', {
		hospital,
		department,
		position
	})
}

// 获取自己的医生信息
export const getDoctorSelf = () => {
	return request.get('/users/doctor/self')
}

// 更新自己的医生信息
export const updateDoctorSelf = (data) => {
	return request.put('/users/doctor/self', data)
}

// 添加患者
export const addPatient = (userId, gender, age, idCard) => {
	return request.post('/users/patient', {
		user_id: userId,
		gender,
		age,
		id_card: idCard
	})
}

// 获取指定患者信息
export const getPatient = (patientUserId) => {
	return request.get(`/users/patient/${patientUserId}`)
}

// 创建评估记录
export const createAssessment = (userId, assessmentDate, hamdTotal, hamaTotal, ymrsTotal) => {
	return request.post('/assessments', {
		user_id: userId,
		assessment_date: assessmentDate,
		hamd_total: hamdTotal,
		hama_total: hamaTotal,
		ymrs_total: ymrsTotal
	})
}

// 提交HAMA量表详情
export const submitHama = (assessmentId, hamaData) => {
	return request.post(`/assessments/${assessmentId}/hama`, hamaData)
}

// 分页查看患者的所有评估记录
export const getPatientAssessments = (patientUserId, page = 1, size = 10) => {
	return request.get(`/assessments/patient/${patientUserId}`, {
		params: {
			page,
			size
		}
	})
}